<template>
    <div>
        <!-- 轮播图区域 -->
      <!-- <swiper :lunbotuList="lunbotuList" :isfull="true"></swiper> -->
      <mt-swipe :auto="4000">
        <mt-swipe-item><img src="../../images/banner1.png" alt=""></mt-swipe-item>
        <mt-swipe-item><img src="../../images/banner2.png" alt=""></mt-swipe-item>
        <mt-swipe-item><img src="../../images/banner6.png" alt=""></mt-swipe-item>
        <mt-swipe-item><img src="../../images/banner7.png" alt=""></mt-swipe-item>
        <mt-swipe-item><img src="../../images/banner8.jpg" alt=""></mt-swipe-item>
      </mt-swipe>
        <!-- 九宫格 到6宫格的改造-->
        <ul class="mui-table-view mui-grid-view mui-grid-9">
             <li><router-link to="/home/newsList">
              <img src="../../images/nav1.png" alt="">
              </router-link></li>
             <li>  <router-link to="/home/photolist">
              <img src="../../images/nav2.png" alt="">
              </router-link></li> 
      
        <li> <router-link to="/home/goodslist">
              <img src="../../images/nav3.png" alt="">
              </router-link></li> 
                 <li> <router-link to="/home/goodslist">
              <img src="../../images/nav4.png" alt="">
              </router-link></li> 
                 <li> <router-link to="/home/goodslist">
              <img src="../../images/nav5.png" alt="">
              </router-link></li> 
           <li> <router-link to="/home/goodsall">
              <img src="../../images/nav6.png" alt="">
              </router-link></li> 
		           </ul>
               
        <div class="goods-list">
           <router-link class="goods-item" v-for="item in goodslist" :key="item.id" :to="'/home/goodsinfo'+ item.id" tag="div">
            <img src="item.pic[i].picAddr" alt="">
            <h1 class="title">{{item.proName}} </h1>
            <div class="info">
                <p class="price">
                    <span class="now">{{item.price}}</span>
                    <span class="old">{{item.old_price}}</span>
                </p>
                <p class="sell">
                    <span>热卖中</span>
                    <span>{{item.mtock_quantity}}</span>
                </p>
            </div> 
            </router-link>
          <div class="goods-item">
            <img src="../../images/detail.jpg" alt="">
            <h1 class="title">adidas阿迪达斯阿迪达斯 男式 场下休闲篮球鞋S83700</h1>
            <div class="info">
                <p class="price">
                    <span class="now">￥2199</span>
                    <span class="old">￥2399</span>
                </p>
                <p class="sell">
                    <span>热卖中</span>
                    <span>剩余60件</span>
                </p>
            </div> 
     </div>
            <div class="goods-item">
                    <img src="../../images/detail.jpg" alt="">
                    <h1 class="title">adidas阿迪达斯阿迪达斯 男式 场下休闲篮球鞋S83700  </h1>
                    <div class="info">
                        <p class="price">
                            <span class="now">￥2199</span>
                            <span class="old">￥2399</span>
                        </p>
                        <p class="sell">
                            <span>热卖中</span>
                            <span>剩余60件</span>
                        </p>
                    </div> 
            </div>
          
            <div class="goods-item">
                    <img src="../../images/detail.jpg" alt="">
                    <h1 class="title">adidas阿迪达斯阿迪达斯 男式 场下休闲篮球鞋S83700  </h1>
                    <div class="info">
                        <p class="price">
                            <span class="now">￥2199</span>
                            <span class="old">￥2399</span>
                        </p>
                        <p class="sell">
                            <span>热卖中</span>
                            <span>剩余60件</span>
                        </p>
                    </div> 
            </div>         
 </div>
      
    </div>
</template>
<script>
import { toast } from "mint-ui";
import swiper from "../subcomponents/swiper.vue";
export default {
  data() {
    return {
      pageindex: 1,
      lunbotuList: [], //保存轮播图
      goodslist:[]
    };
  },
  created() {
    this.getLunbotu();
    this.getGoodsList();
  },
  methods: {
    getLunbotu() {
      this.$http.get("api/getlunbo").then(result => {
        // console.log(result.body);
        if (result.bady.status === 0) {
          // 先循环轮播图数组的每一项 为item 添加img属性，
          // 原因轮播图组件中 只认识item。img，不认识 item。src
          result.bady.message.forEach(item => {
            item.img = item.src;
          });
          this.getLunbotu = this.getLunbotu.message;
        } else {
          //失败
          Toast("加载轮播图失败。。。");
        }
      });
    },
    getGoodsList() {
      //分析：
      //   获取商品的列表
      this.$http
        .get("product/queryProductDetail?pageindex=" + this.pageindex)
        .then(result => {
          if (result.body.status === 0) {
            // this.goodslist=result.body.message;
            this.goodslist = this.goodslist.concat(result.body.message);
          }
        });
    },
    getMore() {
      this.pageindex++;
      this.getGoodsList();
    },
    goDetail(id) {
      // 使用js的形式进行路由导航
      // 1最简单的
      //    this.router.push("/home/goodsinfo/"+id)
      // 2 传递对象
      //   this.$router.push({path: "/home/goodsinfo/" + id});
      // 3.传递命名的路由
      this.router.push({ name: "goodsinfo", params: { id } });
    }
  },
  components: {
    swiper
  }
};
</script>
<style lang="scss" scoped>
.mint-swipe {
  width: 100%;
  height: 200px;
  .mint-swipe-item {
    img {
      width: 100%;
      height: 100%;
    }
  }
}
.mui-grid-view.mui-grid-9 {
  background-color: white;
  padding: 10px;
  border: 0;
li{
  width: 100%;
  img {
    width: 33.333%;
    height:33.333%;
    display: block;
    float: left;
  }
}
  
  .mui-media-body {
    font-size: 13px;
  }
}
.mui-grid-view.mui-grid-9 .mui-table-view-cell {
  border: 0;
}
.goods-list {
  display: flex;
  flex-wrap: wrap;
  padding: 7px;
  justify-content: space-between;
  .goods-item {
    width: 49%;
    padding: 2px;
    margin: 4px 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 293px;
    img {
      width: 100%;
    }
    .title {
      font-size: 14px;
    }
    .info {
      background-color: #eee;
      p {
        margin: 0;
        padding: 5px;
      }
      .price {
        .now {
          color: red;
          font-size: bold;
          font-size: 16px;
        }
        .old {
          text-decoration: line-through;
          font-size: 12px;
          margin-left: 10px;
        }
        .sell {
          display: flex;
          justify-content: space-between;
        }
      }
    }
  }
}
</style>

